package com.rms.hkpc.adapter;

import android.content.Context;

import com.rms.hkpc.R;
import com.rms.hkpc.adapter.base.BaseAdapter;
import com.rms.hkpc.adapter.base.BaseViewHolder;
import com.rms.hkpc.db.dto.WorkOrderRecordDto;

import java.util.List;


public class RecordsAdapter extends BaseAdapter<WorkOrderRecordDto> {


    public RecordsAdapter(Context context, List<WorkOrderRecordDto> mDatas, int layoutId) {
        super(context, mDatas, layoutId);
    }

    @Override
    public void convert(BaseViewHolder holder, WorkOrderRecordDto item, final int position) {
        if (item.getParam() != null) {
            String color;
            if (item.getResult() == 0) {
                color = item.getParam().getFailCol() == null ? "#FF0000" : item.getParam().getFailCol();
            } else {
                color = item.getParam().getPassCol() == null ? "#FF0000" : item.getParam().getPassCol();
            }
            holder.setTextAndColor(R.id.tv_first, item.getName() == null ? "" : item.getName(), color);
            holder.setTextAndColor(R.id.tv_num, String.valueOf(item.getVal()), color);
        }
        holder.setText(R.id.tv_second, item.getwAt() == null ?
                item.getModifyAt() : item.getwAt());
    }
}
